import Vue from "vue";
import VueRouter from "vue-router";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "Home",
    redirect: "/home",
  },
  {
    path: "/home",
    name: "Home",
    meta: {
      keepAlive: true,
    },
    component: () => import("@/views/Home.vue"),
  },
  {
    path: "/emaildetail/:id",
    name: "EmailDetail",
    component: () => import("@/views/EmailDetail.vue"),
  },
  {
    path: "/addUsual/:id",
    name: "addUsual",
    component: () => import("@/components/addUsual.vue"),
  },
  {
    path: "/writemail/:id?",
    name: "WriteMail",
    component: () => import("@/views/WriteMail.vue"),
  },
  {
    path: "/folderManage/:id?",
    name: "FolderManage",
    component: () => import("@/components/folderManage.vue"),
  },
  {
    path: "/loginfail",
    name: "loginfail",
    component: () => import("@/views/loginFail.vue"),
  },
  {
    path: "/networkOffline",
    name: "networkOffline",
    component: () => import("@/views/NetworkOffline.vue"),
  },
];

const router = new VueRouter({
  routes,
});

// router.beforeEach((to, from, next) => {
// if (to.query.isNavHidden) {
//   next();
//   return;
// } else {
// const newTo = {
//   name: to.name,
//   path: to.path,
//   query: Object.assign(to.query, {
//     isNavHidden: true,
//   }),
//   params: to.params,
// };
// if (to.query.replace) {
//   newTo.replace = true;
//   delete to.query.replace;
// }
// next(newTo);
// }

// if(from.query.isNavHidden){
//   let toQuery = JSON.parse(JSON.stringify(to.query))
//   toQuery.isNavHidden = from.query.isNavHidden
//   next({
//     path: to.path,
//     query:toQuery
//   })
// }else{
//   next()
// }
// });

// const to ='https://mtp-test.myoas.com/oppo-mail/?ticket=sss&appid=ssss#/?officeemail=sourceId'
// const index = to.indexOf('#')
// if(index>0){
//   const p =to.slice(0,index)+'&isNavHidden=true'+to.slice(index)
// }
export default router;
